/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ivanbiz.tools;

import java.util.ArrayList;
import java.util.List;

public class RandomList {

    private List list = new ArrayList();
    private String[] data = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
    private String password = "";

    public RandomList() {
        clearRandom();
    }

    private static int doRandom(int batasAtas) {
        int hasil = (int) ((batasAtas) * Math.random());
        return hasil;
    }

    private void clearRandom() {
        list.clear();
    }

    public int getRandom(int batas) {
        int k = 0;
        while (list.size() < batas) {
            k = doRandom(batas);
            if (!list.contains(new Integer(k))) {
                list.add(new Integer(k));
                break;
            }
        }
        return k;
    }

    public String getGenerateKey() {
        String pass = "";
        for (int x = 0; x < 4; x++) {
            int a = (int) (26 * Math.random());
            password += data[a];
        }
        for (int x = 0; x < 6; x++) {
            int a = getRandom(6);
            password += a;
        }
        char[] dataPass = password.toCharArray();
        RandomList rand = new RandomList();
        for (int x = 0; x < 10; x++) {
            int a = rand.getRandom(10);
            pass += dataPass[a];
        }
        return pass;
    }
}
